package com.zhx.bussiness.service;

import com.zhx.business.api.ProductRpc;
import com.zhx.business.repository.dto.ProductCondition;
import com.zhx.business.result.RpcResponseEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Slf4j
@Service
public class ProductRpcService {

    @Autowired
    private ProductRpc productRpc;

    public ResponseEntity list(){
        ProductCondition condition = new ProductCondition();
        Pageable pageable = new PageRequest(0,10);

        ResponseEntity list = productRpc.list(condition, pageable);

        return list;
    }

    public RpcResponseEntity findOne(){
        RpcResponseEntity one = productRpc.findOne("11");

        return one;
    }

    @PostConstruct
    public void testFindAll(){
        RpcResponseEntity list = findOne();

        log.info("返回的对象是:{}",list);
    }

}
